/*
 * @Author: xiaosihan
 * @Date: 2025-01-15 20:24:26
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2025-01-15 20:35:54
 */

import {
  DoubleSide,
  MeshLambertMaterial,
  RepeatWrapping,
  SRGBColorSpace,
  TextureLoader,
} from "three";
import ExtrudeMesh, { ExtrudeMeshProps } from "./ExtrudeMesh";
import roadImgJPG from "./roadImg.jpg";

// 公路对象
export default class Road extends ExtrudeMesh {
  constructor(props: ExtrudeMeshProps) {
    super(props, Road.material);
  }

  // 公路贴图
  static map = (() => {
    const map = new TextureLoader().load(roadImgJPG);
    map.wrapS = map.wrapT = RepeatWrapping;
    map.colorSpace = SRGBColorSpace;
    return map;
  })();

  // 公路的材质
  static material = new MeshLambertMaterial({
    map: this.map,
    side: DoubleSide,
  });
}
